<script setup>
import { ref } from 'vue';

const formData = ref({
  currentPassword: '',
  newPassword: '',
  confirmPassword: ''
});

const handleSavePassword = () => {
  // 这里实现密码修改逻辑
  console.log('密码修改请求：', formData.value);
  // 实际项目中应该调用API
};

const handleCancel = () => {
  formData.value = {
    currentPassword: '',
    newPassword: '',
    confirmPassword: ''
  };
};
</script>

<template>
  <div class="form-section">
    <h2 class="section-title">账户安全</h2>
    
    <div class="form-group">
      <label>当前密码</label>
      <input type="password" placeholder="请输入当前密码" v-model="formData.currentPassword">
    </div>
    
    <div class="form-group">
      <label>新密码</label>
      <input type="password" placeholder="请输入新密码" v-model="formData.newPassword">
      <div class="hint">密码至少包含8个字符，建议使用字母、数字和特殊字符的组合</div>
    </div>
    
    <div class="form-group">
      <label>确认密码</label>
      <input type="password" placeholder="请再次输入新密码" v-model="formData.confirmPassword">
    </div>
    
    <div class="form-actions">
      <button class="save-btn" @click="handleSavePassword">修改密码</button>
      <button class="cancel-btn" @click="handleCancel">取消</button>
    </div>
  </div>
</template>

<style scoped>
.form-section {
  animation: slideIn 0.6s ease-out forwards;
  opacity: 0.1;
}

@keyframes slideIn {
  0% {
    opacity: 0.1;
    transform: translateX(20px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

.section-title {
  font-size: 1.4rem;
  color: #333;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}

.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  font-size: 0.95rem;
  color: #555;
  margin-bottom: 8px;
}

.hint {
  font-size: 0.85rem;
  color: #888;
  margin-top: 8px;
}

input {
  width: 100%;
  height: 46px;
  padding: 0 15px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.3s, box-shadow 0.3s;
}

input:focus {
  border-color: #00c389;
  box-shadow: 0 0 0 2px rgba(0, 195, 137, 0.2);
  outline: none;
}

.form-actions {
  display: flex;
  gap: 15px;
  margin-top: 30px;
  animation: fadeUp 0.8s ease-out forwards;
  animation-delay: 0.4s;
  opacity: 0.1;
}

@keyframes fadeUp {
  0% {
    opacity: 0.1;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.save-btn {
  padding: 12px 30px;
  background-color: #00c389;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.save-btn:hover {
  background-color: #00b07b;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 195, 137, 0.3);
}

.cancel-btn {
  padding: 12px 30px;
  background-color: #f8f9fa;
  color: #555;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.cancel-btn:hover {
  background-color: #f0f0f0;
}
</style> 